<template>
    <div>
        <i-select placeholder="二级分类" @on-change="selectTwo">
            <i-option v-for="item in list" :value="item.value" v-bind:key="item.label">{{item.value}}</i-option>
        </i-select>
    </div>
</template>
<script>
    import configService from 'service/configService.js'
    export default {
        name: 'levelTwo',
        props: {

        },
        data() {
            return {
                list:[],
            }
        },
        methods: {
            async getLevelTwoList() {
                let jsondata = await configService.getQuestionTypeList()
                if (jsondata.children) {
                    jsondata.children.forEach((item, index) => {
                        item.value = item.attributes.serviceName;
                        item.label = item.attributes.serviceId;
                        // console.log(item.label);
                        if (item.children && item.children.length > 0) {
                            item.children.forEach((val, i) => {
                                val.value = val.attributes.serviceName
                                val.label = val.attributes.serviceId
                            })
                            this.list = item.children;
                        }else{
                            
                        }
                    })
                }
            },
            selectTwo(curropt) {
                this.$emit('getLevelTwo',curropt)
            }
        },
        created(){
            this.getLevelTwoList();
        }
    }
</script>